package io.renren.controller;

import io.renren.common.utils.R;
import io.renren.common.utils.RedisUtils;
import io.renren.service.impl.ActiveMQProducerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.activemq.command.ActiveMQQueue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: 63461
 * @Date: 2019/2/13 08:29
 * @Description:
 */
@RestController
@RequestMapping("/activeMQ")
@Api(tags = "activeMQ接口")
public class ApiActiveMQController {

    @Autowired
    private ActiveMQProducerService producer;
    @Autowired
    private RedisUtils redisUtils;

    @PostMapping("test")
    @ApiOperation("activemq测试")
    public R test() {
        producer.sendMessage(new ActiveMQQueue("wechat.sms.queue"), "我叫小明");
        redisUtils.set("name", "123123213");
        redisUtils.get("name");
        return R.ok();
    }

    @PostMapping("thread")
    @ApiOperation("thread测试")
    public void thread() {
//        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ThreadAsyncConfigurer.class);
//        AsyncTaskService asyncTaskService = context.getBean(AsyncTaskService.class);
//        for (int i = 0; i < 10; i++) {
//            asyncTaskService.executeAsyncTask(i);
//            asyncTaskService.executeAsyncTaskPlus(i);
//        }
    }
}
